home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / forms / frmwiz / fieldfrm.frm < prev    next >
Text File  |  1995-01-14  |  11KB  |  395 lines

  1. VERSION 2.00
  2. Begin Form FieldFrm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Form Wizard - Field Selection"
  6.    ClientHeight    =   5115
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1260
  9.    ClientWidth     =   7845
  10.    ControlBox      =   0   'False
  11.    Height          =   5520
  12.    HelpContextID   =   26
  13.    Icon            =   FIELDFRM.FRX:0000
  14.    Left            =   1035
  15.    LinkTopic       =   "Form2"
  16.    ScaleHeight     =   5115
  17.    ScaleWidth      =   7845
  18.    Top             =   915
  19.    Width           =   7965
  20.    Begin SSCommand BtnHelp 
  21.       Caption         =   "&Help"
  22.       Font3D          =   2  'Raised w/heavy shading
  23.       Height          =   615
  24.       Left            =   4860
  25.       Picture         =   FIELDFRM.FRX:0302
  26.       TabIndex        =   11
  27.       Top             =   4020
  28.       Width           =   915
  29.    End
  30.    Begin SSPanel cMsg 
  31.       Align           =   2  'Align Bottom
  32.       Alignment       =   1  'Left Justify - MIDDLE
  33.       BevelInner      =   1  'Inset
  34.       BorderWidth     =   2
  35.       Height          =   375
  36.       Left            =   0
  37.       TabIndex        =   10
  38.       Top             =   4740
  39.       Width           =   7845
  40.    End
  41.    Begin SSCommand BtnFinish 
  42.       AutoSize        =   2  'Adjust Button Size To Picture
  43.       Caption         =   "&Finish"
  44.       Enabled         =   0   'False
  45.       Font3D          =   2  'Raised w/heavy shading
  46.       Height          =   615
  47.       Left            =   3960
  48.       Picture         =   FIELDFRM.FRX:0604
  49.       TabIndex        =   9
  50.       Top             =   4020
  51.       Width           =   915
  52.    End
  53.    Begin SSCommand BtnCancel 
  54.       AutoSize        =   2  'Adjust Button Size To Picture
  55.       Caption         =   "&Cancel"
  56.       Font3D          =   2  'Raised w/heavy shading
  57.       Height          =   615
  58.       Left            =   3060
  59.       Picture         =   FIELDFRM.FRX:0906
  60.       TabIndex        =   6
  61.       Tag             =   "Cancel building the form"
  62.       Top             =   4020
  63.       Width           =   915
  64.    End
  65.    Begin SSCommand BtnNext 
  66.       AutoSize        =   2  'Adjust Button Size To Picture
  67.       Caption         =   "&Next"
  68.       Font3D          =   2  'Raised w/heavy shading
  69.       Height          =   615
  70.       Left            =   2160
  71.       Picture         =   FIELDFRM.FRX:0C08
  72.       TabIndex        =   5
  73.       Tag             =   "Proceed to the next step"
  74.       Top             =   4020
  75.       Width           =   915
  76.    End
  77.    Begin SSCommand BtnPrev 
  78.       AutoSize        =   2  'Adjust Button Size To Picture
  79.       Caption         =   "&Previous"
  80.       Font3D          =   2  'Raised w/heavy shading
  81.       Height          =   615
  82.       Left            =   1260
  83.       Picture         =   FIELDFRM.FRX:0F0A
  84.       TabIndex        =   4
  85.       Tag             =   "Return to the previous step"
  86.       Top             =   4020
  87.       Width           =   915
  88.    End
  89.    Begin SSFrame FramFldsOnForm 
  90.       Alignment       =   2  'Center
  91.       Caption         =   "Fields On Form"
  92.       ForeColor       =   &H00FF0000&
  93.       Height          =   3675
  94.       Left            =   3900
  95.       TabIndex        =   8
  96.       Top             =   240
  97.       Width           =   3795
  98.       Begin Grid GrdFields 
  99.          Cols            =   4
  100.          FixedRows       =   0
  101.          Height          =   3315
  102.          Left            =   120
  103.          Rows            =   1
  104.          TabIndex        =   2
  105.          Tag             =   "Select one or more fields, right click to change attributes"
  106.          Top             =   240
  107.          Width           =   3555
  108.       End
  109.    End
  110.    Begin SSFrame Frame3D1 
  111.       Alignment       =   2  'Center
  112.       Caption         =   "Select Fields For Form"
  113.       ForeColor       =   &H00FF0000&
  114.       Height          =   3735
  115.       Left            =   120
  116.       TabIndex        =   7
  117.       Top             =   180
  118.       Width           =   2595
  119.       Begin ListBox LstFields 
  120.          BackColor       =   &H00C0C0C0&
  121.          Height          =   3345
  122.          Left            =   120
  123.          MultiSelect     =   2  'Extended
  124.          TabIndex        =   0
  125.          Tag             =   "Select one or more fields to add to the form"
  126.          Top             =   300
  127.          Width           =   2355
  128.       End
  129.    End
  130.    Begin SSCommand BtnRemove 
  131.       AutoSize        =   2  'Adjust Button Size To Picture
  132.       Caption         =   "&Remove"
  133.       Font3D          =   2  'Raised w/heavy shading
  134.       Height          =   555
  135.       Left            =   2820
  136.       Picture         =   FIELDFRM.FRX:120C
  137.       TabIndex        =   3
  138.       Tag             =   "Remove selected field(s) from the form"
  139.       Top             =   1200
  140.       Width           =   975
  141.    End
  142.    Begin SSCommand BtnAdd 
  143.       AutoSize        =   2  'Adjust Button Size To Picture
  144.       Caption         =   "&Add"
  145.       Font3D          =   2  'Raised w/heavy shading
  146.       Height          =   555
  147.       Left            =   2820
  148.       Picture         =   FIELDFRM.FRX:150E
  149.       TabIndex        =   1
  150.       Tag             =   "Add selected field(s) to the form"
  151.       Top             =   600
  152.       Width           =   975
  153.    End
  154. End
  155. Option Explicit
  156. Dim maxwidth(3) As Long
  157.  
  158. Sub BtnAdd_Click ()
  159.     Dim i As Integer, fld As String
  160.  
  161.     ' Add selected feilds to grid
  162.     For i = 0 To LstFields.ListCount - 1
  163.         If LstFields.Selected(i) Then
  164.             fld = LstFields.List(i)
  165.             GrdFields.AddItem fld & Chr$(9) & fld & Chr$(9) & "No" & Chr$(9) & Str$(aiFldSize(i))
  166.             If TextWidth(fld) + 150 > maxwidth(0) Then
  167.                 maxwidth(0) = TextWidth(fld) + 150
  168.                 GrdFields.ColWidth(0) = maxwidth(0)
  169.             End If
  170.             If TextWidth(fld) + 150 > maxwidth(1) Then
  171.                 maxwidth(1) = TextWidth(fld) + 150
  172.                 GrdFields.ColWidth(1) = maxwidth(1)
  173.             End If
  174.         End If
  175.     Next i
  176.     If GrdFields.Rows > 1 Then GrdFields.FixedRows = 1
  177.  
  178. End Sub
  179.  
  180. Sub BtnAdd_GotFocus ()
  181.     cMsg.Caption = BtnAdd.Tag
  182.  
  183. End Sub
  184.  
  185. Sub BtnCancel_Click ()
  186.     EndItNow
  187.  
  188. End Sub
  189.  
  190. Sub BtnCancel_GotFocus ()
  191.     cMsg.Caption = BtnCancel.Tag
  192.  
  193. End Sub
  194.  
  195. Sub BtnHelp_Click ()
  196.     SendKeys "{F1}"
  197.  
  198. End Sub
  199.  
  200. Sub BtnNext_Click ()
  201.     Dim contanyway As Integer
  202.     Dim msg As String
  203.     If GrdFields.Rows = 1 Then
  204.         Beep
  205.         msg = "You haven't specified any fields for the form!  Do you want to continue anyway?"
  206.         contanyway = MsgBox(msg, MB_ICONQUESTION + MB_YESNO, "Field Selection")
  207.         If contanyway = IDNO Then
  208.             Exit Sub
  209.         End If
  210.     End If
  211.     
  212.     GenForm.Show MODELESS
  213.     FieldFrm.Hide
  214.  
  215. End Sub
  216.  
  217. Sub BtnNext_GotFocus ()
  218.     cMsg.Caption = BtnNext.Tag
  219.  
  220. End Sub
  221.  
  222. Sub BtnPrev_Click ()
  223.     DataSpec.Show MODELESS
  224.     FieldFrm.Hide
  225.  
  226. End Sub
  227.  
  228. Sub BtnPrev_GotFocus ()
  229.     cMsg.Caption = BtnPrev.Tag
  230.  
  231. End Sub
  232.  
  233. Sub BtnRemove_Click ()
  234.     On Error GoTo removeerr
  235.     Dim i As Integer, i2 As Integer
  236.     
  237.     ' Remove any selected rows except the last one
  238.     For i = GrdFields.Rows - 2 To 0 Step -1
  239.         GrdFields.Row = i
  240.         GrdFields.Col = 1
  241.         If GrdFields.CellSelected Then
  242.             GrdFields.RemoveItem i
  243.         End If
  244.     Next i
  245.     
  246.     ' Check if last row is deleted and handle special to prevent error
  247.     ' caused by selection defaulting to the entire table when the last
  248.     ' row is removed
  249.     i = GrdFields.Rows - 1
  250.     GrdFields.Row = i
  251.     GrdFields.Col = 1
  252.     If GrdFields.CellSelected Then
  253.         GrdFields.FixedRows = 0
  254.         GrdFields.RemoveItem i
  255.     End If
  256.     GrdFields.Refresh
  257.     If GrdFields.Rows > 1 Then GrdFields.FixedRows = 1
  258.  
  259.     Exit Sub
  260.  
  261. removeerr:
  262.     erraction = RB_ErrorHandler("FieldFrm", "BtnRemove_Click")
  263.     Select Case erraction
  264.     Case 1
  265.         Resume 0      ' Retry option selected
  266.     Case 2
  267.         Resume Next   ' Ignore option selected
  268.     End Select
  269.  
  270. End Sub
  271.  
  272. Sub BtnRemove_GotFocus ()
  273.     cMsg.Caption = BtnRemove.Tag
  274.  
  275. End Sub
  276.  
  277. Sub Form_Activate ()
  278.     Dim ds As dynaset, ssfields As snapshot
  279.     Dim iNumFlds As Integer
  280.     On Error GoTo formacterr
  281.  
  282.     ' Load list of fields in record source
  283.     If NewRecordSource Then
  284.         Set ds = db.CreateDynaset(DataSpec.LstRecSrce.Text)
  285.         Set ssfields = ds.ListFields()
  286.         ds.Close
  287.         LstFields.Clear
  288.         ReDim aiFldSize(1)
  289.         iNumFlds = -1
  290.         Do While Not ssfields.EOF
  291.             LstFields.AddItem ssfields!Name
  292.             iNumFlds = iNumFlds + 1
  293.             ReDim Preserve aiFldSize(iNumFlds)
  294.             aiFldSize(iNumFlds) = ssfields!Size
  295.             ssfields.MoveNext
  296.         Loop
  297.         ssfields.Close
  298.         NewRecordSource = False
  299.         ' Clear the grid of fields
  300.         GrdFields.Rows = 1
  301.     End If
  302.  
  303.     Exit Sub
  304.  
  305. formacterr:
  306.     erraction = RB_ErrorHandler("FieldFrm", "Form_Activate")
  307.     Select Case erraction
  308.     Case 1
  309.         Resume 0      ' Retry option selected
  310.     Case 2
  311.         Resume Next   ' Ignore option selected
  312.     End Select
  313.     
  314. End Sub
  315.  
  316. Sub Form_Load ()
  317.     On Error GoTo loaderr
  318.  
  319.     ' Set up grid headings
  320.     GrdFields.Row = 0
  321.     GrdFields.Col = 0
  322.     GrdFields.Text = "Field"
  323.     GrdFields.ColWidth(0) = TextWidth(" Field ")
  324.     maxwidth(0) = GrdFields.ColWidth(0)
  325.     GrdFields.Col = 1
  326.     GrdFields.Text = "Label"
  327.     GrdFields.ColWidth(1) = TextWidth(" Label ")
  328.     maxwidth(1) = GrdFields.ColWidth(1)
  329.     GrdFields.Col = 2
  330.     GrdFields.Text = "Same" & Chr$(13) & "Line"
  331.     GrdFields.ColWidth(2) = TextWidth(" Same ")
  332.     maxwidth(2) = GrdFields.ColWidth(2)
  333.     GrdFields.Col = 3
  334.     GrdFields.Text = "Size"
  335.     GrdFields.ColWidth(3) = TextWidth(" Size ")
  336.     GrdFields.RowHeight(0) = 2 * TextHeight("Same")
  337.  
  338.     Exit Sub
  339.  
  340. loaderr:
  341.     erraction = RB_ErrorHandler("FieldFrm", "Form_Load")
  342.     Select Case erraction
  343.     Case 1
  344.         Resume 0      ' Retry option selected
  345.     Case 2
  346.         Resume Next   ' Ignore option selected
  347.     End Select
  348.  
  349. End Sub
  350.  
  351. Sub Form_Resize ()
  352.     If FieldFrm.WindowState <> 1 Then
  353.         FramFldsOnForm.Width = FieldFrm.Width - FramFldsOnForm.Left - 250
  354.         GrdFields.Width = FramFldsOnForm.Width - GrdFields.Left - 150
  355.     End If
  356.  
  357. End Sub
  358.  
  359. Sub GrdFields_GotFocus ()
  360.     cMsg.Caption = GrdFields.Tag
  361.  
  362. End Sub
  363.  
  364. Sub GrdFields_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  365.     Dim i As Integer, istart As Integer, iend As Integer
  366.     If Button = RIGHT_BUTTON Then
  367.         istart = GrdFields.SelStartRow
  368.         If istart = 0 Then istart = 1
  369.         iend = GrdFields.SelEndRow
  370.         For i = istart To iend
  371.             GrdFields.Row = i
  372.             GrdFields.Col = 0
  373.             ChngFld.LblField.Caption = GrdFields.Text
  374.             GrdFields.Col = 1
  375.             ChngFld.TxtLabel = GrdFields.Text
  376.             GrdFields.Col = 2
  377.             If GrdFields.Text = "Yes" Then
  378.                 ChngFld.ChkSameLine.Value = True
  379.             Else
  380.                 ChngFld.ChkSameLine.Value = False
  381.             End If
  382.             ChngFld.LblRow.Caption = Str$(i)
  383.             ChngFld.Show MODAL
  384.         Next i
  385.     End If
  386.  
  387.  
  388. End Sub
  389.  
  390. Sub LstFields_GotFocus ()
  391.     cMsg.Caption = LstFields.Tag
  392.  
  393. End Sub
  394.  
  395.